using System;
using System.Linq;
using NUnit.Framework;
using SharpTestsEx;

namespace AltNetHispano.Vale.Tests
{
	public class PolimorphismMixingClassAndInterfaceTests
	{
		private interface IHasName
		{
			string Name { get; }
		}
		public class Contact : IHasName
		{
			public string NickName { get; set; }

			public string Name {get; set;}
		}

		public class Person : Contact
		{
			public string Surname { get; set; }
		}

		[Test]
		public void WhenValidatePersonThenShouldApplyRulesOfContactAndHasName()
		{
			var validator = new Validator();
			validator.Register<IHasName>(c => validator.StringIsRequired("Name", c.Name));
			validator.Register<Contact>(c => validator.StringIsRequired("Nick Name", c.NickName));
			validator.Register<Person>(p => validator.StringIsRequired("Surname", p.Surname));

			var person = new Person();
			var invalidMessages = validator.GetInvalidMessages(person).ToArray();
			invalidMessages.Should().Have.Count.EqualTo(3);
		}

	}
}